
package com.jsg.sl651.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 风向枚举
 */
@Getter
@AllArgsConstructor
public enum WindDirectionEnum {
    NORTH(1, "北"),
    NORTH_NORTHEAST(2, "东北北"),
    NORTHEAST(3, "东北"),
    EAST_NORTHEAST(4, "东北东"),
    EAST(5, "东"),
    EAST_SOUTHEAST(6, "东南东"),
    SOUTHEAST(7, "东南"),
    SOUTH_SOUTHEAST(8, "东南南"),
    SOUTH(9, "南"),
    SOUTH_SOUTHWEST(10, "西南南"),
    SOUTHWEST(11, "西南"),
    WEST_SOUTHWEST(12, "西南西"),
    WEST(13, "西"),
    WEST_NORTHWEST(14, "西北西"),
    NORTHWEST(15, "西北"),
    NORTH_NORTHWEST(16, "西北北"),
    OTHER(0, "其他");

    private final int code;
    private final String name;

    public static WindDirectionEnum getByCode(int code) {
        for (WindDirectionEnum windDirectionEnum : WindDirectionEnum.values()) {
            if (windDirectionEnum.getCode() == code) {
                return windDirectionEnum;
            }
        }
        return OTHER;
    }
}